package com.calciominoBeta.Activity;

import com.calciominoBeta.R;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.MotionEvent;

public class SplashScreenActivity extends Activity implements Runnable {
	Thread mThread;
	Runnable mRunnable;
	boolean active = true;
	int mTime = 200;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.splashscreen_activity);
		
//		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
//				WindowManager.LayoutParams.FLAG_FULLSCREEN);

	}

	@Override
	protected void onResume() {
		active = true;
		mTime = 200;
		super.onResume();
	}

	@Override
	public void onWindowFocusChanged(boolean hasFocus) {
		if (mThread == null) {
			mThread = new Thread(this);
			mThread.start();
		}
		super.onWindowFocusChanged(hasFocus);
	}

	@Override
	public void run() {
		try {
			while (active && mTime > 0) {
				mTime -= 10;
				Thread.sleep(20);

			}
		} catch (Exception e) {
		} finally {
			startActivity(new Intent(getBaseContext(), Main_Activity.class));
			finish();
		}

	}

	@Override
	public boolean onTouchEvent(MotionEvent event) {
		if (event.getAction() == MotionEvent.ACTION_DOWN) {
			active = false;
		}
		return super.onTouchEvent(event);
	}

}
